package com.hellpro.lolbox.video.presenter;

import android.text.TextUtils;
import android.widget.ArrayAdapter;

import com.hellpro.lolbox.utils.ToastShowCenter;
import com.hellpro.lolbox.video.view.fragment.IVideoSearchActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * 类描述:
 * 创建人:阿犇
 * 创建时间:2016/10/27
 * 备注:
 */

public class VideoSearchPresenter {

    private IVideoSearchActivity mIVideoSearchActivity;
    public VideoSearchPresenter(IVideoSearchActivity iVideoSearchActivity){
        this.mIVideoSearchActivity = iVideoSearchActivity;
    }

    /**
     *
     * 类描述:
     * 创建人:阿犇
     * 创建时间:2016/10/27
     * 备注:处理搜索页面
     */

    public void setSearch(){
        String msg = mIVideoSearchActivity.getEtInput().getText().toString().trim();
        if (TextUtils.isEmpty(msg)) {
            ToastShowCenter.centerToast(mIVideoSearchActivity.getSearchContext(),"搜索内容不能为空");
        } else {
            //模拟数据
            List<String> list = new ArrayList<>();
            list.add("1啦啦啦啦，德玛西亚");
            list.add("2人在塔在");
            list.add("3我的大刀早已饥渴难耐");
            list.add("4长枪依在");
            list.add("5双眼失明");
            if (msg.contains("1") || msg.contains("2") || msg.contains("3")|| msg.contains("4")|| msg.contains("5")) {
                //改变状态
                ArrayAdapter<String> adapter = new ArrayAdapter<>(mIVideoSearchActivity.getSearchContext(), android.R.layout.simple_list_item_1, list);
                mIVideoSearchActivity.getSearchLv().setAdapter(adapter);
            }else {
                ToastShowCenter.centerToast(mIVideoSearchActivity.getSearchContext(),"搜索内容不存在");
            }
        }
    }
}
